package org.liulinlin.sejw.db;

import java.sql.*;

public class AnswerPriceForm { //extends DataAccessServiceImpl {
	private int id;
	private java.sql.Date time;
	private String timeString;
	private QueryPriceForm queryPriceForm;
	private double shippingCost;
	private double landCost;
	private double declareCost;
	private double orderCost;
	private String comment;
	
	public AnswerPriceForm(int id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from AnswerPriceForm where APF_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			time = rs.getDate("APF_Time");
			timeString = time.toString();
			queryPriceForm = new QueryPriceForm(id);
			shippingCost = rs.getDouble("APF_ShippingCost");
			landCost = rs.getDouble("APF_LandCost");
			declareCost = rs.getDouble("APF_DeclareCost");
			orderCost = rs.getDouble("APF_OrderCost");
			comment = rs.getString("APF_Comment");
			
			rs.close();
			stmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public AnswerPriceForm() {
		//super();
	}
	
	public void setId(int id) {
		this.id = id;
	}
	public void setTime(java.sql.Date time) {
		this.time = time;
	}
	public void setTimeString(java.sql.Date time) {
		this.timeString = time.toString();
	}
	public void setQueryPriceForm(QueryPriceForm queryPriceForm) {
		this.queryPriceForm = queryPriceForm;
	}
	public void setShippingCost(double shippingCost) {
		this.shippingCost = shippingCost;
	}
	public void setLandCost(double landCost) {
		this.landCost = landCost;
	}
	public void setDeclareCost(double declareCost) {
		this.declareCost = declareCost;
	}
	public void setOrderCost(double orderCost) {
		this.orderCost = orderCost;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	public int getId() {
		return id;
	}
	public java.sql.Date getTime() {
		return time;
	}
	public String getTimeString() {
		return timeString;
	}
	public QueryPriceForm getQueryPriceForm() {
		return queryPriceForm;
	}
	public double getShippingCost() {
		return shippingCost;
	}
	public double getLandCost() {
		return landCost;
	}
	public double getDeclareCost() {
		return declareCost;
	}
	public double getOrderCost() {
		return orderCost;
	}
	public String getComment() {
		return comment;
	}
}
